<html>
<head>
    <script>
        let heap;
        let importObject = {
            env: {
                log: strIndex => {
                    let str = '';
                    for (let i = strIndex; heap[i] !== 0; i++) {
                        str += String.fromCharCode(heap[i]);
                    }

                    console.log(str);
                }
            }
        };

        WebAssembly.instantiateStreaming(fetch('main.wasm'), importObject)
            .then(result => {
                const exports = result.instance.exports;
                heap = new Uint8Array(exports.memory.buffer);
                exports.main();
            });
    </script>
</head>
<body>
<div id="console"></div>
</body>
</html>